<?php

namespace app\api\controller\xykeep;
use app\common\controller\Api;
use addons\xykeep\service\Distribution as DistributionService;
use app\api\model\xykeep\distribution\Commission as CommissionModel;

class Distribution extends Api
{

    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * 分销商详情
     */
    public function info()
    {
        $user = $this->auth->getUserinfo();
        $distribution = new DistributionService($user['id']);
        $distributionInfo = $distribution->getDistributionInfo();
        $distributionInfo['data']['one_child_num'] = $distribution->getOneChildNum();
        $distributionInfo['data']['two_child_num'] = $distribution->getTwoChildNum();

        if ($distribution->isDistributionAvaliable()) {
            $distributionInfo['data']['level'] = $distribution->getDistributionLevelInfo();
        }

        $this->success('分销商详情', $distributionInfo);
    }



    /**
     * 用户团队
     */
    public function team()
    {
        $params = $this->request->post();
        $user = $this->auth->getUserinfo();
        $distribution = new DistributionService($user['id']);
        $team = $distribution->getTeamList($params);
        $this->success('我的团队', $team);
        
    }

    /**
     * 账单(佣金明细)
     */
    public function bill()
    {
        $params = $this->request->post();
        $data = CommissionModel::getLists($params);
        $this->success('佣金明细', $data);
    }

    
}
